﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace myLittleC
{
    class ComExeption : Exception, IComError
    {
        public ERRORS mErrorCode{get; private set;}
        TPosition mPos;


        public ComExeption(ERRORS iErrorCode) { mErrorCode = iErrorCode;}
        public ComExeption(ERRORS iErrorCode, TPosition iPos):this(iErrorCode) {   mPos = iPos;}



        public ERRORS ErrorCode { get{ return mErrorCode; }}
        public override String ToString() { return ErrorMessage;}
        public TPosition Position { get { return mPos; } }

        public String ErrorMessage
        {
            get
            {
                String Message = "";
                if (ErrorCode == ERRORS.EOF)
                    Message = "Don't find finish of file";
                else if (ErrorCode == ERRORS.UnknownError)
                    Message = "Unknown error";
                else if (ErrorCode == ERRORS.InvalidConstInt)
                    Message = "Bad integer const";
                else if (ErrorCode ==ERRORS.InvalidConstFloat)
                    Message = "Bad float const";
                else if (ErrorCode == ERRORS.InvalidConstString)
                    Message = "Bad const String";
                else if (ErrorCode == ERRORS.InvalidEscSeq)
                    Message = "Bad Esc Sting";
                else if (ErrorCode == ERRORS.BadExpression)
                    Message = "Bad Expression";
                else if (ErrorCode == ERRORS.BadUnaryExp)
                    Message = "Bad Unary Expression";
                else if (ErrorCode == ERRORS.UnExpRightParan)
                    Message = "Don't find )";
                else if (ErrorCode ==ERRORS.BadLValue)
                    Message = "l-value must be variable";
                else if (ErrorCode ==ERRORS.BadDeclaration)
                    Message = "Bad Declaration";
                else if (ErrorCode ==ERRORS.DublDeclaration)
                    Message = "Item With This Name had Defined";
                else if (ErrorCode == ERRORS.NotDefType)
                    Message = "Don't Define Type";
                else if (ErrorCode == ERRORS.NotUnicDef)
                    Message = "Item With This Name had Defined";
                else if (ErrorCode == ERRORS.UnExpSemicolon)
                    Message = "dont find \";\"";
                else if (ErrorCode == ERRORS.NotArraySize)
                    Message = "have not Array Size ";
                else if (ErrorCode == ERRORS.UnExpRBreak)
                    Message = "Unexpected \"]\"";
                else if (ErrorCode == ERRORS.CantDefsVar)
                    Message = "Can't Define var";
                else if (ErrorCode == ERRORS.UnExpFinRace)
                     Message = "Unexpected \"}\"";
                else if (ErrorCode == ERRORS.UnExpIdent)
                    Message = "Unexpected Identificator";
                else if (ErrorCode == ERRORS.UnExpType)
                    Message = "UnIndefened Type";
                else if (ErrorCode == ERRORS.UnIdefSymbol)
                    Message = "UnIndefened Symbol construction";
                else if (ErrorCode == ERRORS.CantDefsFunk)
                    Message = "Can't Define function";
                else if (ErrorCode == ERRORS.CanDefsExpr)
                    Message = "Can't Define Expresion"; 
				else if (ErrorCode == ERRORS.EmpryStruct)
                    Message = "Can't Define Empty Struct"; 
				else if (ErrorCode == ERRORS.NotUnicDefOrCantDefsFunk)
					Message = "Item With This Name had Defined or cant Define Funk";
                else
                    Message = "Don't define Error";
                      
               return String.Format("ERROR: {0}, in {1}", Message, Position);
            }
        }

        class ParseException : Exception
        {
            public ERRORS ErrorCode { get; private set; }

            public String ErrorMessage()
            {
                return "";
            }

            
            public override String ToString() { return ErrorMessage(); }
        }
    }
}
